package com.ynjtc.desserts.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ynjtc.desserts.entity.User;
import com.ynjtc.desserts.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: lihua
 * @Date: 2025/9/15 10:56
 * @Version: v1.0.0
 * @Description:
 **/
@Service
@Slf4j
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public void register(User user){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",user.getUsername());
        if(userMapper.exists(queryWrapper)){
            log.error("用户已存在 username ==> {}",user.getUsername());
        }else {
            userMapper.insert(user);
            log.debug("用户注册成功");
        }
    }

}
